<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>购物车</title>
    <script type="text/javascript" src="/SVN/DR/Public/Js/home/jquery-1.11.3.js"></script>
    <script type="text/javascript" src="/SVN/DR/Public/Js/layer/layer.js"></script>
    <script>
        //要写在user_common.js调用之前     因tp框架中定义的常量，在外部调用的js中不能被解析
        var tp_defined = {'url': '/SVN/DR/index.php/Home/User'};
    </script>
    <script type="text/javascript" src="/SVN/DR/Public/Js/home/user_common.js"></script>
    <link rel="stylesheet" type="text/css" href="/SVN/DR/Public/Css/home/cart.css">
    <script>
        $(function () {
            var checkbox = $('.shop_tabble input:checkbox');
            if (checkbox.length == 0) {
                return;
            }
            //全选
            $('.save .all').click(function () {
                checkbox.prop('checked', true);
            });
            //全不选
           /* $('.save .none').click(function () {
                checkbox.prop('checked', false);
            });*/
            //反选
            $('.save .reverse').click(function () {
                for (var i = 0; i < checkbox.length; i++) {
                    if (checkbox.eq(i).prop('checked')) {
                        checkbox.eq(i).prop('checked', false);
                    } else {
                        checkbox.eq(i).prop('checked', true);
                    }
                }
            });
            //商品数量和价格的动态变动
            $(document).click(function () {
                //获取选择的商品数
                var checked_num = $('.shop_tabble input:checkbox:checked');
                //$('.checked_num').html(checked_num.length);
                //获取选取商品的总价
                var good_num = 0;
                var total = 0;
                if(checked_num.length!=0){
                    for (var i = 0; i < checked_num.length; i++) {
                        var td = checked_num.eq(i).parents('tr');
                        good_num += parseInt(td.children('.good_num').children('span').text());
                        total += parseInt(td.children('.good_total').text());
                    }
                    $('.end_bt').css({'background-color':'#D6B870','cursor':'pointer'});
                    $('.end_bt').attr('onclick','submitOrder()');
                }else{
                    $('.end_bt').css({'background-color':'#B0B0B0','cursor':''});
                    $('.end_bt').removeAttr('onclick');
                }
                $('.checked_num').html(good_num);
                $('.fw_bold').html('￥' + total);
            });
        });
        //提交订单  填写收货地址
        function submitOrder(){
            //获取选择的商品的购物车对应的id
            $('#orderForm').submit();
        }
    </script>
</head>
<body>
<!--全部背景-->
<div class="all-thing">
    <!--中间内容-->
    <div class="tcmain">
        <!--引入购物车头部文件-->
        <!--头部-->
<div class="shop_top">
    <div class="shopt_left fl">
        <a href="/SVN/DR/index.php/Home/Index/index" title="Darry Ring">
            <img src="/SVN/DR/Public/Images/home/dr.png" height="42" width="186">
        </a>
    </div>
    <div class="shopt_right fr">
        <span id="ctl00_ltlUname"><a href="/SVN/DR/index.php/Home/User/index">你好！<?php echo (session('user_tel')); ?></a></span>
        <!--<a href="/SVN/DR/index.php/Home/User/index" class="my_dr">我的DR</a>-->
        <a href="/SVN/DR/index.php/Home/Index/logout" class="tc_dr">退出</a>
        <!--<a href="/SVN/DR/index.php/Home/Help/index" class="help_dr">帮助中心</a>-->
    </div>
</div>
<!--头部end-->
        <!--导航条-->
        <div id="ctl00_showNav" class="shop_spnav"></div>
        <!--导航条end-->
        <!--内容-->
        <div class="shop_cort">
            <form method="post" action="/SVN/DR/index.php/Home/User/sureOrder" id="orderForm">
                <!--左边-->
                <div class="shop_cort-left fl">
                    <!--<h3>查看我的购物车</h3>-->
                    <!--购物车-->
                    <div class="save">
                        <a href="javascript:void(0)" class="all">全选</a>
                        <!--<a href="javascript:void(0)" class="none">全不选</a>-->
                        <a href="javascript:void(0)" class="reverse">反选</a>
                    </div>
                    <table class="shop_tabble" border="0" cellpadding="0" cellspacing="0">
                        <tr class="nav_tr">
                            <td class="gm_td"></td>
                            <td class="sp_td">商品</td>
                            <td class="cz_td">材质</td>
                            <!--<td class="sc_td">手寸/尺寸</td>
                            <td class="kz_td">刻字</td>-->
                            <td class="kz_td">单价(￥)</td>
                            <td class="kz_td">购买量</td>
                            <td class="gm_td">购买价(￥)</td>
                        </tr>
                        <?php if((count($cart_data)) == "0"): ?><tr>
                                <td colspan="7">购物车空空的，去寻找真爱吧 :)</td>
                            </tr><?php endif; ?>
                        <?php if(is_array($cart_data)): foreach($cart_data as $key=>$v): ?><tr class="nav_tr_main">
                                <td><input type="checkbox" name="checked[]" value="<?php echo ($v['id']); ?>"></td>
                                <td class="sp_td"><a href="/SVN/DR/index.php/Home/Goods/details/id/<?php echo ($v['goods_detail_id']); ?>"><?php echo ($v['goods_style']); echo ($v['goods_name']); ?></a></td>
                                <td>
                                    <?php switch($v['material']): case "0": ?>白18K金<?php break;?>
                                        <?php case "1": ?>PT950<?php break; endswitch;?>
                                </td>
                                <!--<td><?php echo ($v['size']); ?></td>
                                <td><?php echo ($v['carve']); ?></td>-->
                                <td class="good_price"><?php echo ($v['price']); ?></td>
                                <td class="good_num">
                                    <a href="javascript:num_change(<?php echo ($v['id']); ?>,'cut')" class="cut">-</a>
                                    <span class="cart_<?php echo ($v['id']); ?>"><?php echo ($v['num']); ?></span>
                                    <a href="javascript:num_change(<?php echo ($v['id']); ?>,'add')" class="add">+</a>
                                </td>
                                <td class="good_total"><?php echo ($v['price']*$v['num']); ?></td>
                            </tr><?php endforeach; endif; ?>
                    </table>
                    <!--购物车end-->

                    <!--结算-->
                    <div class="shop_js">
                        <div class="left">
                            <a href="javascript:delCart();" class="del_shop">删除选中项</a>
                            <a href="javascript:clearCart();" class="qk_shop">清空购物车</a>
                            <a href="/SVN/DR/index.php/Home/Goods/index" class="jx_shop">继续购物</a>
                        </div>
                        <div class="right">
                            <span>你选择了<i class="checked_num">0</i>件商品</span>
                            <span>总计：<i class="fw_bold" style="font-family: 微软雅黑;">￥0</i></span>
                            <span class="end_bt"><em>立即结算</em></span>
                        </div>
                    </div>
                    <!--结算end-->
                </div>
                <!--左边end-->
            </form>
            <!--引入购物车右侧文件-->
            <!--右边-->
<div class="shop_cort-right fr">
    <div class="shop_right-nr">
        <h3>购物帮助指南</h3>
        <div class="shop_right-zx line_bottom">
            <p class="shop_lx">24小时在线客服</p>
            <p class="shop_tel">400-01-13520</p>
        </div>
        <div class="shop_right-zf line_bottom">
            <h4>支付安全保障</h4>
            <p>安全支付系统采用SSL加密。</p>
            <ul class="shop_right-ul">
                <li class="shop_cor-yl"></li>
                <li class="shop_cor-cft"></li>
                <li class="shop_cor-zf"></li>
            </ul>
        </div>
        <div class="shop_right-ps">
            <h4>全球配送</h4>
            <p class="shop_kd">支持全球配送,店铺取货</p>
            <p class="shop_bj">全程保价 无风险</p>
        </div>
    </div>
</div>
<!--右边end-->
        </div>
        <!--引入购物车底部文件-->
        <!--底部-->
<div class="cmain shop_foot">
    <p>Copyright © 2006-2015 www.darryring.com 戴瑞珠宝 All Rights Reserved. 粤ICP备11012085号</p>
    <p>中国互联网违法信息举报中心 | 中国公安网络110报警服务 | 本网站提供所售商品的正式发票</p>
    <div class="shop_foot-img">
        <img src="/SVN/DR/Public/Images/home/db.jpg" height="55" width="776">
    </div>
</div>
<!--底部end-->
    </div>
    <!--全部背景end-->
</div>
</body>
</html>